import { IObject, udp } from '@cscec/udp-mobile-ui';
/**
 * 获取列表数据
 * @param param 参数
 * @returns
 */

export async function getList({ pageIndex, pageSize, ...queryFilter }: IObject) {
  try {
    const {
      code,
      data: { list: record, total }
    } = await udp.request.body({
      url: '/api/textbook/list',
      data: {
        pageIndex,
        pageSize,
        queryfilter: queryFilter
      }
    });
    return code === 200 ? { total, record } : { total: 0, record: [] };
  } catch (e) {
    return { total: 0, record: [] };
  }
}
/**
 * 获取列表数据
 * @param param 参数
 * @returns
 */

export async function queryDetail(param) {
  try {
    const { code,data} = await udp.request.get({
      url:'/api/textbook/queryDetail',
      data:param
    });
    return code === 200 ? data:'报错信息';
  } catch (e) {
    return { total: 0, list: [] };
  }
}

/**
 * 获取列表数据
 * @param param 参数
 * @returns
 */

export async function importUnitExcel() {
  try {
    const {
      code,
      data
    } = await udp.request.get({
      url:'/textbook/importUnitExcel'
    });
    return code === 200 ? data:'报错信息';
  } catch (e) {
    return { total: 0, list: [] };
  }
}